<!--
 * @Author: sundl
 * @Date: 2021-04-12 16:00:29
 * @project: 天津YQ平台
-->

<template>
  <dg-row>
    <ModuleCard>
      <template v-slot:header>值班信息</template>
      <el-row :span="24">
        <el-col :span="12">当日值守：{{ zsMap[form.drzsCode] }}</el-col>
        <el-col :span="12">今日指挥长：{{ zhzMap[form.drzhzCode] }}</el-col>
      </el-row>
    </ModuleCard>
  </dg-row>
</template>

<script>
import ModuleCard from '@/components/layout/module-card';
import { findJrzs, findDrzhz } from '@/api/common';

export default {
  name: 'duty-info',
  components: {
    ModuleCard
  },
  data() {
    return {
      form: {},
      jrzs: [
        // {
        //   id: '',
        //   name: ''
        // }
      ],
      zhz: []
    };
  },
  computed: {
    zsMap(){
      let result = {};

      if (!_.isEmpty(this.jrzs)){
        this.jrzs.forEach(item => {
          result[item['id']] = item['name'];
        });
      }

      return result;
    },
    zhzMap(){
      let result = {};

      if (!_.isEmpty(this.zhz)){
        this.zhz.forEach(item => {
          result[item['id']] = item['name'];
        });
      }

      return result;
    }
  },
  methods: {
    onUpdateInfo(data) {
      this.form = data.signInVO;
    },
    getJrzs(){ // 请求今日值守
      findJrzs().then(({ data }) => {
        this.jrzs = data;
      });
    },
    getZhz(){ // 请求指挥长
      findDrzhz().then(({ data }) => {
        this.zhz = data;
      });
    }
  },
  mounted() {
  },
  created() {
    // 查询今日值守
    this.getJrzs();
    // 查询今日指挥长
    this.getZhz();
  }
};
</script>

<style></style>
